//
//  Stadium.m
//  Soccer
//
//  Created by Hyun-Woong Kim on 09. 05. 28.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "Stadium.h"
#import "ClientManager.h"


@implementation Stadium

- (id)initWithSize:(CGSize)size groundBounds:(CGRect)groundBounds goalPostSize:(CGSize)goalPostSize
{
	if (self = [super init])
	{
		size_ = size;
		groundBounds_ = groundBounds;
		float goalPostY = groundBounds.origin.y + groundBounds.size.height / 2 - goalPostSize.height / 2;
		teamAGoalPostBounds_ = CGRectMake(groundBounds.origin.x, goalPostY, goalPostSize.width, goalPostSize.height);
		teamBGoalPostBounds_ = CGRectMake(groundBounds.origin.x + groundBounds.size.width - goalPostSize.width, goalPostY, goalPostSize.width, goalPostSize.height);
//		teamAGoalPostBounds_ = teamAGoalPostBounds;
//		teamBGoalPostBounds_ = teamBGoalPostBounds;
	}
	return self;
}

@synthesize size=size_;
@synthesize groundBounds=groundBounds_;
@synthesize teamAGoalPostBounds=teamAGoalPostBounds_;
@synthesize teamBGoalPostBounds=teamBGoalPostBounds_;

- (NSString *)getFileName
{
	return @"Stadium.png";
}

- (void)spriteNeedsUpdates:(ObjectSprite *)sprite
{	
	CGPoint cameraPosition = [[ClientManager sharedManager].match getCameraPosition];
	CGPoint adjustedCameraPosition = CGPointMake(cameraPosition.x - sprite.transformAnchor.x, cameraPosition.y - sprite.transformAnchor.y);
	
	float x, y, z;
	[sprite.camera eyeX:&x eyeY:&y eyeZ:&z];
	[sprite.camera setEyeX:adjustedCameraPosition.x eyeY:adjustedCameraPosition.y eyeZ:z];
	
	[sprite.camera centerX:&x centerY:&y centerZ:&z];
	[sprite.camera setCenterX:adjustedCameraPosition.x centerY:adjustedCameraPosition.y centerZ:z];
}

@end
